import os

s = os.sep
root_dir = os.path.curdir
extensions = [r'.xml', r'.java']


def count_dir(root_dir):
    line_count = 0
    file_count = 0
    for rt, dirs, files in os.walk(root_dir):
        for f in files:
            fname = os.path.splitext(f)
            # print fname
            for ext in extensions:
                # print ext
                if ext.__eq__(fname[1]):
                    line_count += len(open(os.path.join(rt, f), 'rU').readlines())
                    file_count += 1
                    break
    return line_count, file_count


if '__main__' == __name__:
    print count_dir(root_dir)

